// ****************************************************************
// Copyright 2012, Stephan Burguchev
// e-mail: me@sburg.net
// ****************************************************************
// *
using System.IO;
using System.Xml.Serialization;

namespace Updater.Common
{
    [XmlRoot("inter-process-data")]
    public class InterProcessData
    {
        private static readonly XmlSerializer _ipdSerializer = new XmlSerializer(typeof(InterProcessData));

        [XmlArray("change-log")]
        [XmlArrayItem("change-log-record")]
        public ChangeLogRecord[] ChangeLog { get; set; }

        [XmlElement("configuration")]
        public Configuration Configuration { get; set; }

        [XmlElement("restart-application")]
        public bool RestartApplication { get; set; }

        [XmlArray("updates-to-apply")]
        [XmlArrayItem("update-information")]
        public UpdateInformation[] UpdatesToApply { get; set; }

        public static InterProcessData Deserialize(Stream stream)
        {
            var ipd = (InterProcessData)_ipdSerializer.Deserialize(stream);
            return ipd;
        }

        public void Serialize(Stream outStream)
        {
            _ipdSerializer.Serialize(outStream, this);
        }
    }
}
